import { _decorator, Component, Label, labelAssembler, Node } from 'cc';
import { HttpUtil } from '../Framework/Managers/HttpUtil';
import { UICtrl } from '../Framework/Managers/UICtrl';
const { ccclass, property } = _decorator;

@ccclass('Recording')
export class Recording extends UICtrl {

    @property(Label)
    private detaLabel:Label;
    @property(Label)
    private stateLabel:Label;

    @property(Label)
    private killedStatistics1:Label;
    @property(Label)
    private killedStatistics2:Label;
    @property(Label)
    private killedStatistics3:Label;
    @property(Label)
    private killedStatistics4:Label;
    @property(Label)
    private killedStatistics5:Label;
    @property(Label)
    private killedStatistics6:Label;
    @property(Label)
    private killedStatistics7:Label;
    @property(Label)
    private killedStatistics8:Label;
    @property(Label)
    private assassinStats1:Label;
    @property(Label)
    private assassinStats2:Label;
    @property(Label)
    private assassinStats3:Label;
    @property(Label)
    private assassinStats4:Label;
    @property(Label)
    private assassinStats5:Label;
    @property(Label)
    private assassinStats6:Label;
    @property(Label)
    private assassinStats7:Label;
    @property(Label)
    private assassinStats8:Label;
    @property(Label)
    private assassinStats9:Label;
    @property(Label)
    private assassinStats10:Label;
    @property(Label)
    private roomLabel1:Label;
    @property(Label)
    private roomLabel2:Label;
    @property(Label)
    private roomLabel3:Label;
    @property(Label)
    private roomLabel4:Label;
    @property(Label)
    private roomLabel5:Label;
    @property(Label)
    private roomLabel6:Label;
    @property(Label)
    private roomLabel7:Label;
    @property(Label)
    private roomLabel8:Label;
    @property(Label)
    private roomLabel9:Label;
    @property(Label)
    private roomLabel10:Label;
    @property(Label)
    private roomId:Label;
    @property(Label)
    private killerRoomId:Label;
    
    private roomName = ["办公室","储藏室","会客厅","研究室","活动室","会客厅","音乐室","保卫室"]
    start() {
        HttpUtil.get("/api/detail",{houseId:0,userId:100},(state,data)=>{
            this.Recording(state,data);
        })
    }
    onLoad(): void {
        super.onLoad();
        
    }
    update(deltaTime: number) {
        
    }
    Recording(bool,data){
        console.log("data",data);
        let gameRecord = data.gameRecord;
        let beKillRecord = data.beKillRecord;
        let killRecord = data.killRecord;
        if(gameRecord.length>0){
            this.roomId.getComponent(Label).string = "" +this.roomName[gameRecord[0].RoomId];
            this.killerRoomId.getComponent(Label).string = "" +this.roomName[gameRecord[0].KillRoomId];
            this.detaLabel.getComponent(Label).string = "第XXXXX期  " +this.roomName[gameRecord[0].CreateTime];
            if(gameRecord[0].RoomId == gameRecord[0].KillRoomId){
                this.detaLabel.getComponent(Label).string = "躲避失败";
            }else{
                this.detaLabel.getComponent(Label).string = "躲避成功";
            }
            
        }
        if(beKillRecord.length>0){
            for(let i = 0;i<beKillRecord.length;i++){
                this["killedStatistics"+(i+1)].getComponent(Label).string = "" +beKillRecord[i].Time;
            }
            
        }
        if(killRecord.length>0){
            for(let i = 0;i<killRecord.length;i++){
                console.log("i",i,this["assassinStats"+(i+1)])
                this["assassinStats"+(i+1)].getComponent(Label).string = "第" +killRecord[i].Phase+"期";
                this["roomLabel"+(i+1)].getComponent(Label).string = "" +this.roomName[killRecord[0].RoomId];
            }
           
        }

        

    }
    clickReturn(){
        this.node.destroy();
    }
}


